import { Component } from '@angular/core';
import {Platform, Events, NavController, App} from 'ionic-angular';
import { StatusBar, Splashscreen } from 'ionic-native';
import { TabsPage } from '../pages/tabs/tabs';
import { BackgroundMode, LocalNotifications } from 'ionic-native';
import { Keyboard } from 'ionic-native';
import {AppService} from "../services/AppService";
import {LoginPage} from "../pages/login/login";

@Component({
  templateUrl: 'app.html'
})
export class MyApp {
  rootPage = TabsPage;

  constructor(platform: Platform, app_service: AppService, app: App, events: Events) {
    platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      StatusBar.styleDefault();
      Splashscreen.hide();
      BackgroundMode.enable();

      Keyboard.hideKeyboardAccessoryBar(true);
      Keyboard.disableScroll(true);


      events.subscribe('app:unauthenticated', () => {
        //navCtrl.setRoot(LoginPage);
        app.getRootNav().setRoot(LoginPage);

      });

      app_service.redirectIfNotLogin();
    });
  }
}
